---
page_title: "cloudflare_healthcheck Resource - Cloudflare"
subcategory: ""
description: |-
  Standalone Health Checks provide a way to monitor origin servers
  without needing a Cloudflare Load Balancer.
---

# cloudflare_healthcheck (Resource)

Standalone Health Checks provide a way to monitor origin servers
without needing a Cloudflare Load Balancer.

## Example Usage

```terraform
# HTTPS Healthcheck
resource "cloudflare_healthcheck" "http_health_check" {
  zone_id = var.cloudflare_zone_id
  name = "http-health-check"
  description = "example http health check"
  address = "example.com"
  suspended = false
  check_regions = [
    "WEU",
    "EEU"
  ]
  type = "HTTPS"
  port = 443
  method = "GET"
  path = "/health"
  expected_body = "alive"
  expected_codes = [
    "2xx",
    "301"
  ]
  follow_redirects = true
  allow_insecure = false
  header {
    header = "Host"
    values = ["example.com"]
  }
  timeout = 10
  retries = 2
  interval = 60
  consecutive_fails = 3
  consecutive_successes = 2
}

# TCP Healthcheck
resource "cloudflare_healthcheck" "tcp_health_check" {
  zone_id = var.cloudflare_zone_id
  name = "tcp-health-check"
  description = "example tcp health check"
  address = "example.com"
  suspended = false
  check_regions = [
    "WEU",
    "EEU"
  ]
  type = "TCP"
  port = 22
  method = "connection_established"
  timeout = 10
  retries = 2
  interval = 60
  consecutive_fails = 3
  consecutive_successes = 2
}
```
<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `address` (String) The hostname or IP address of the origin server to run health checks on.
- `name` (String) A short name to identify the health check. Only alphanumeric characters, hyphens, and underscores are allowed.
- `type` (String) The protocol to use for the health check. Available values: `TCP`, `HTTP`, `HTTPS`.
- `zone_id` (String) The zone identifier to target for the resource. **Modifying this attribute will force creation of a new resource.**

### Optional

- `allow_insecure` (Boolean) Do not validate the certificate when the health check uses HTTPS. Defaults to `false`.
- `check_regions` (List of String) A list of regions from which to run health checks. If not set, Cloudflare will pick a default region. Available values: `WNAM`, `ENAM`, `WEU`, `EEU`, `NSAM`, `SSAM`, `OC`, `ME`, `NAF`, `SAF`, `IN`, `SEAS`, `NEAS`, `ALL_REGIONS`.
- `consecutive_fails` (Number) The number of consecutive fails required from a health check before changing the health to unhealthy. Defaults to `1`.
- `consecutive_successes` (Number) The number of consecutive successes required from a health check before changing the health to healthy. Defaults to `1`.
- `description` (String) A human-readable description of the health check.
- `expected_body` (String) A case-insensitive sub-string to look for in the response body. If this string is not found the origin will be marked as unhealthy.
- `expected_codes` (List of String) The expected HTTP response codes (e.g. '200') or code ranges (e.g. '2xx' for all codes starting with 2) of the health check.
- `follow_redirects` (Boolean) Follow redirects if the origin returns a 3xx status code. Defaults to `false`.
- `header` (Block Set) The HTTP request headers to send in the health check. It is recommended you set a Host header by default. The User-Agent header cannot be overridden. (see [below for nested schema](#nestedblock--header))
- `interval` (Number) The interval between each health check. Shorter intervals may give quicker notifications if the origin status changes, but will increase the load on the origin as we check from multiple locations. Defaults to `60`.
- `method` (String) The HTTP method to use for the health check. Available values: `connection_established`, `GET`, `HEAD`.
- `path` (String) The endpoint path to health check against. Defaults to `/`.
- `port` (Number) Port number to connect to for the health check. Defaults to `80`.
- `retries` (Number) The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. Defaults to `2`.
- `suspended` (Boolean) If suspended, no health checks are sent to the origin. Defaults to `false`.
- `timeout` (Number) The timeout (in seconds) before marking the health check as failed. Defaults to `5`.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only

- `created_on` (String) Creation time.
- `id` (String) The ID of this resource.
- `modified_on` (String) Last modified time.

<a id="nestedblock--header"></a>
### Nested Schema for `header`

Required:

- `header` (String) The header name.
- `values` (Set of String) A list of string values for the header.


<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String)

## Import

Import is supported using the following syntax:

```shell
# Use the Zone ID and Healthcheck ID to import.
$ terraform import cloudflare_healthcheck.example <zone_id>/<healthcheck_id>
```
